//
//  ZJBloodViewController.swift
//  mini
//
//  Created by Mac on 2017/5/19.
//  Copyright © 2017年 Mac. All rights reserved.
//

import UIKit

class ZJBloodViewController: UIViewController {
    
    let view1 = UIView()
    let view2 = UIView()
    let view3 = UIView()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "血压计"
        
         addBackButton()
         shishiLayOut()
        
        // Do any additional setup after loading the view.
    }
    
    
    func shishiLayOut() {
        
        view1.backgroundColor = .red
        view2.backgroundColor = .blue
        view3.backgroundColor = .yellow
        view.addSubview(view1)
        view.addSubview(view2)
        view.addSubview(view3)
        let layoutGuide = UILayoutGuide()
        view.addLayoutGuide(layoutGuide)
        let layoutGuide1 = UILayoutGuide()
        view.addLayoutGuide(layoutGuide1)
        let layoutGuide2 = UILayoutGuide()
        view.addLayoutGuide(layoutGuide2)
        let layoutGuide3 = UILayoutGuide()
        view.addLayoutGuide(layoutGuide3)
        let ss:NSAttributedString  = NSAttributedString.cz_imageText(with: #imageLiteral(resourceName: "bluetooth_on"), imageWH: 20, title: "hahah", fontSize: 20, titleColor: .red, spacing: 10)
        
        
        let label = UILabel(frame: CGRect(x: 100, y: 100, width: 100, height: 30))
        
        label.attributedText = ss
        
//        label.backgroundColor = .red
        
        view.addSubview(label)
            
            
        
        
        
        layoutGuide.snp.makeConstraints { (make) in
            
            make.centerY.equalTo(self.view)
            make.left.equalTo(self.view)
              make.height.equalTo(10)
        }
        
        view1.snp.makeConstraints { (make) in
            
            make.centerY.equalTo(layoutGuide)
            make.left.equalTo(layoutGuide.snp.right)
            make.width.equalTo(layoutGuide)
            make.height.equalTo(10)
        }
        layoutGuide1.snp.makeConstraints { (make) in
            
            make.centerY.equalTo(layoutGuide)
            make.left.equalTo(self.view1.snp.right)
            make.width.equalTo(self.view1)
              make.height.equalTo(10)
        }
        view2.snp.makeConstraints { (make) in
            
            make.centerY.equalTo(layoutGuide)
            make.left.equalTo(layoutGuide1.snp.right)
            make.width.equalTo(layoutGuide1)
              make.height.equalTo(10)
        }
        layoutGuide2.snp.makeConstraints { (make) in
            
            make.centerY.equalTo(layoutGuide)
            make.left.equalTo(self.view2.snp.right)
            make.width.equalTo(self.view2)
              make.height.equalTo(10)
        }
        view3.snp.makeConstraints { (make) in
            
            make.centerY.equalTo(layoutGuide)
            make.left.equalTo(layoutGuide2.snp.right)
            make.width.equalTo(layoutGuide2)
              make.height.equalTo(10)
        }
        layoutGuide3.snp.makeConstraints { (make) in
            
            make.centerY.equalTo(layoutGuide)
            make.left.equalTo(self.view3.snp.right)
            make.width.equalTo(self.view3)
            make.right.equalTo(self.view)
              make.height.equalTo(10)
        }
        
    }
    
    func addBackButton() {
        
        let btn:ZJNavButton = ZJNavButton(frame: CGRect(x: 0, y: 0, width: 19, height: 19))
        
        btn.setImage(#imageLiteral(resourceName: "back"), for: .normal)
        
        btn.addTarget(self, action: #selector(back), for: .touchUpInside)
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: btn)
        
    }
    
    @objc func back()  {
        dismiss(animated: true, completion: nil);
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
